const isChar = function (c) {
    // console.log(c);
    if (c >= 'a' && c <= 'z') {
        return true;
    } else {
        return false;
    }
};
const isDigit = function (c) {
    if (c >= '0' && c <= '9') {
        return true;
    } else {
        return false;
    }
};
/**
 * 递归法
 * "3[a]2[bc]rrrr"
 * @param {*} str 
 * @param {*} i 
 * @returns 
 */
function dfs(str = "", i) {
    let res = [];
    let mult = 0;
    while (i < str.length) {
        if (isDigit(str[i])) {
            mult = mult * 10 + Number(str[i]);
        } else if (str[i] === "[") {
            let tmp = dfs(str, i + 1);
            i = Number(tmp[0]);
            while (mult > 0) {
                res.push(tmp[1]);
                mult--;
            }// res =[cc,cc]
        } else if (str[i] === ']') {
            return [i, res.join("")]
        } else {
            res.push(str[i]);
        }
        i++;
    }
    return res.join("");
}
